-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move SET_BRK_CALL_TO()s in funcs.c to resolve issue #917 #1814
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me, though (as you acknowledge already) tests should be added; i.e. add new files to tst/test-error/
, say based on your two original examples, and the corresponding .out
files (created with the regenerate_error_tests.sh
), which demonstrate the new fixed output.
src/funcs.c
Outdated
** 'ARGI_CALL(<call>,<i>)'. It discards the value returned by the function | ||
** and returns the statement execution status (as per EXEC_STAT, q.v.) | ||
** resulting from the procedure call, which appears always to be 0, with the | ||
** only possible exception occurring in case the user quit during the call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment change is not mentioned in the commit message. That should be done, or else, a separate commit be added which performs this change
That said, the ExecProccall*args
functions really always return 0, period. So both the new and the old comment are misleading.
Codecov Report
@@ Coverage Diff @@
## master #1814 +/- ##
==========================================
+ Coverage 50.44% 63.05% +12.6%
==========================================
Files 448 968 +520
Lines 234445 292773 +58328
Branches 10446 12924 +2478
==========================================
+ Hits 118268 184608 +66340
+ Misses 113385 105366 -8019
- Partials 2792 2799 +7
|
OK, added test and fixed comment (sorry I couldn't tell whether that ReadEvalError() might do some sort of non-local exit, so I hedged a bit in the comment). Hope all is well now. |
Well, of course the function could "exit" non-locally via a "thrown exception" (if this was C++ code; we do something similar using |
Good point on the terminology. I suppose a macro could have literally returned a different value, but the camel case indicated quite strongly that ReadEvalError() was not a macro. I guess I just get antsy whenever I see "error handling" functions, sorry. Thanks for moving these changes along. |
I see the Travis CI failed in the test "testerror" -- which seems odd because there is no testerror.g in the gap source code tree... Let me know if there's anything I can do to lend a hand. |
You can run
These tests aren't run by a GAP file, because they involve running lots of GAPs. I imagine you are hitting the |
Sorry, went to have a look, something weird is happening. Will investigate. |
Ah, I see what's happened. We've renamed If you rebase your commit, it should test fine. Not sure how
|
Did I succeed? Sadly I am not that experienced with git. So I just tried your commands, and the last one failed with "fatal: The current branch fix/master/issue_917 has no upstream branch." So I messed around a bit, trying to follow the clues git was giving me, and couldn't get it to work unless I did a "git pull origin fix/master/issue_917". Then the push worked; hope it was all OK; I didn't really understand the commands I was issuing. |
Sometimes git just goes crazy. I have made a new commit, #1821, which is (I hope!) just a cleaned up version of your commit. If you could just check I didn't break it (I'm fairly sure I didn't, I diffed the two versions. I did merge the 3rd commit into the 1st. |
@ChrisJefferson in git advice, it's generally not a good idea to assume that |
You are right, I gave bad advice. I suggest we move over to #1821 (where I've hopefully cleaned things up) |
Sorry I wasn't experienced enough with git to know properly how to do what @ChrisJefferson was asking me to. I will switch over to pull request #1821; this one can be closed (should I do that?) |
We can close by just clicking "close and comment" at the bottom. I just left it open to check you were happy, and didn't get confused by the PR just disappearing. Don't worry, git can behave strangely, and it's sometimes hard to debug remotely (to be honest, I find it hard to debug when I'm in front of a computer using it sometimes..) |
Reopening as per @fingolfin's suggestion in #1821 |
The diffs look as expected, so I think/hope I have executed the instructions from @fingolfin in #1821 for fixing this pull request correctly. I will now check in the further changes he requested and tests for them. |
Ok, and now I have made the changes suggested by @fingolfin in his code review in #1821, along with tests for them. This was a good catch, because all of the new test cases segfault without the change. Thanks! |
Actually, I don't think there is need to test the full backtrace for the second fix. So the test can live in a plain.tst file - I'd just add it to ˋtst/testinstall/callfunc.tstˋ |
Right, that's what I did, except I put it in testbugfix (which doesn't test the full backtrace like test-error does), since that's where it was suggested that I put the test for my recent fix to MagmaWithOne and MagmaWithInverses with two arguments.Should I move the test for this part to testinstall? |
Calling into non-function objects was mostly undocumented, unknown, and buggy in all GAP version up to and including GAP 4.8.x. So 4.9 will be the first were this is usable. Hence, I wouldn't put the test under "bugfix", but rather into the normal testsuite. Indeed, I'd always prefer to put tests there; I only place tests into I'd also keep the tests as simple, short and self-contained as possible. For that reason, I really would advice against using Hence, the test should go into
|
informproc0 := function(l) | ||
Add(l,1); | ||
l(); | ||
return; end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, why the return;
? It is redundant, isn't it?
Perhaps also add a second semicolon after end;
, to suppress printing the function, to reduce clutter in the .out
file.
l(); | ||
return; end; | ||
informproc0([]); | ||
quit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps insert Print("\n\n");
after each quit;
, to make the output a bit more readable?
OK, I think I have covered all of your requests for changes. Thanks for the feedback. |
@gwhitney Thanks. In principle, this could be merged now, but if you want to aim for "perfection", then you could still slightly improve the commit structure and messages. For example, the second commit has the commit message "Add a test to tst/test-error verifying behavior in all cases changed" which doesn't make much sense if read in isolation -- and it'll be read in isolation at times. So it's better to make that self-contained, or at the very least make clear it refers to, e.g. by saying "... in all cases changed by the previous commit. However, in this case, I actually think it would make more sense to squash the first two commits together, and also the last three. If you would like to try that, you can do it with an "interactive rebase". And if anything goes wrong, you can abort this operation (I'll tell you how). So, you do this: checkout your branch. Then enter the command So, you'd change the word "pick" in the second line to "s" (indicating to git that you want to squash the second commit into the second), and also in lines 4 and 5 (so that commits 4 and 5 get squashed into commit 3). Once you changed the commands like that, you can save the file and exit the editor, at which point git starts to work. It'll open the editor two more times, to let you edit the commit message for the two resulting commits. The default will be the concatenation of the commit messages of the commits being squashed together, but you can of course freely edit those. |
OK, that all worked on my laptop, but (sorry to be a dope) when I then naively tried
How do I transmit the revised PR back to the mother ship? Thanks! |
Sorry, forgot the last step: you need to pass the option |
Should have guessed. But I am always slightly frightened of using excessive force, I figure there's more chance to break things... ;-) |
Thanks. However, now there is a new annoyance: the second commit contains some changes/fixes that belong into the first commit, namely tweaks to If you are still with me and not fed up by me annoying you with constant change requests, I'll describe how to fix this below. However, if you rather would not, just let me know, and I'll take care of it (I am simply telling these things to you in case you'd like to learn; it is not my intention to "punish" you for being helpful to us!!!) Anyway, here is what you could do: Change into your clone of the GAP repo, and to your branch. Now enter the command So now do Git should now have transferred the changes to the first commit... And you can (If anything during this fails: no worries, git keeps backups of everything, and we can revert to those. |
The invocations of SET_BRK_CALL_TO() in funcs.c should each occur _before_ the respective calls to DispatchFuncCall so that if there is an error within that DispatchFuncCall, the backtrace will show appropriate information. In addition: - Improved the comment documenting ExecProccall... functions, to reflect that they discard rather than return the values from the interior function call. - Added a test to tst/test-error verifying the backtrace behavior when errors do occur, in all cases changed.
This is a follow-up to the change moving the SET_BRK_CALL_TO() invocations, to also share the postprocessing after DispatchFuncCall with the "traditional" function call. This has the benefit of preventing e.g. segfaults should the DispatchFuncCall fail to return an object when it is supposed to. In addition, added tests to tst/testinstall/callfunc.tst to cover the behavior of GAP in such error cases as just mentioned. (Thanks @fingolfin for the guidance on the structure of these tests.)
Kay, as requested. Impressed with your patience for enforcing crispness at the individual-commit level, as opposed to the level of merges into the repository master (which obviously have to be clean and focused). I guess if I ever embark on any serious project on the GAP codebase I will have to replay all of my changes and shuffle them into neat units before submitting a pull request, since in my experience actual development never really follows such an orderly step-by-step process as the final pair of commits in this PR would represent. Anyhow, how about as a reward for my being a good student of git ;-), you take a quick look at the pull request to endow DirectProductElements with a working String() method (I won't put the PR number here since it isn't really a contentful cross reference)? The fact that String() is choking on DPEs is blocking me from working on my actual project (working with the authors of LOOPS and some other researchers on a better-integrated rack/quandle package that could get in shape for refereeing) on top of master. |
First off, thanks for updating the commits, they are fine now :-). I also commented on the other PR. As to your other remarks: Enforcing "crispness" on the commit level pays off on the long run, namely when you need to debug a regression via Many companies sadly fail to do this well, claiming there is no time to do things "properly" -- in my personal experience (e.g. woking as a programming freelancer during my studies, and talking about this with friends who work in IT), this very often comes with severe penalties as the projects "mature", and it's doubtful whether the time saved by rushing things vs. the time lost due to not being able to navigate the mess, is really worth it ... shrug. Anyway, The reason I spend time trying to teach people this is selfish: I hope they'll learn to "do it properly" next time, thus saving time for everybody... Finally, of course I don't write new code like that, I make crazy commits with horrible commit messages etc., and then once a feature is complete, I go through the mess once and sort it into something that makes sense. With some practice and routine, that doesn't waste much time, but pays of (in my experience, at least) later, as describe above. |
Consider the following interaction with a freshly-compiled gap from master; it is essentially the same phenomenon as the first example in #917, albeit with the offending bit of code as a procedure call rather than a function:
I included the opening banner so that you can easily count the lines in stdin and see that the backtrace is misreporting the expression in which the error (namely that there is no method for the function-call syntax with the function object being a list) occurs and the line on which it occurred. But now contrast that session with the following one:
Now the error message is corretly showing that the offending code was at line 3, and it lies in "l( )" (there's still no method for the function call of a list object). The difference might be mysterious until you look at code in funcs.c and compare ExecProccall0args, in which SET_BRK_CALL_TO() occurs before the DispatchFuncCall, with ExecProccall1args, in which SET_BRK_CALL_TO() occurs after the DispatchFuncCall. Examining the remaining ExecProc... and EvalFunc... functions suggests that similar bad behavior will occur in all of those corresponding cases, and sure enough, I have attached a transcript of the remaining 12 cases displaying misleading information.
It appears that when the code to allow arbitrary objects to implement the function call syntax was added, in almost all (but thankfully not all, otherwise I would have been very unlikely to find this) cases the DispatchFuncCall was added "too early" in the various ExecProc... and EvalFunc... functions. This pull request moves the SET_BRK_CALL_TO()s uniformly before the DispatchFuncCall, and the other attachment shows a transcript of all 14 cases suppling more informative messages.
I will update the pull request with a test based on the latter transcript as soon as I figure out how the extended testing for the full backtrace added in pull request #918 works.
issue_917_examples.txt
issue_917_corrected.txt
Resolves #917.